//
//  ViewController.m
//  weak和assign
//
//  Created by 李煜 on 2023/5/23.
//

#import "ViewController.h"

@interface ViewController ()

@property (nonatomic, assign) UIButton *assignBtn;
@property (nonatomic, weak) UIButton *weakButton;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(100,100,100,100)];
    [btn setTitle:@"Test" forState:UIControlStateNormal];
    btn.backgroundColor = [UIColor lightGrayColor];
    self.assignBtn = btn;
    self.weakButton = btn;
    NSLog(@"这时候打印self.assignBtn，self.weakButton 此时打印两个button，没有区别");
    //如果加上如下 btn = nil
    btn = nil;
    NSLog(@"这时候打印self.assignBtn，self.weakButton 就会crash问题");
    NSLog(@"self.weakBtn = %@",self.weakButton);
//    NSLog(@"self.assignBtn = %@",self.assignBtn);


    //    NSLog(@"------: %s",__FILE__);
}


@end
